define([], function (require, exports) {
  exports.ready = function (hashCode, data, cite) {
    yufp.custom.vue({
      el: cite.el,
      data: function () {
        var _self = this;
        return {
          urls: {
            index: backend.workflowService + '/api/bench/copy'
          },
          tableColumns: [
            {
              label: '流程实例号',
              prop: 'instanceId',
              resizable: true,
              template: function () {
                return '<template scope="scope">\
                                <a style="text-decoration:underline;cursor:pointer;" @click="_$event(\'custom-detail-click\', scope.row)">{{scope.row.instanceId}}</a>\
                            </template>';
              }
            },
            { label: '流程名称', prop: 'flowName', resizable: true, hidden: true},
            { label: '业务流水号', prop: 'bizId', resizable: true},
            { label: '客户名称', prop: 'bizUserName', resizable: true},
            { label: '客户用户名', prop: 'bizUserId', resizable: true},
            { label: '开始时间', prop: 'startTime', resizable: true},
            { label: '节点处理人', prop: 'userId', resizable: true},
            { label: '节点编号', prop: 'nodeId', resizable: true},
            { label: '节点处理人', prop: 'userName', hidden: true, resizable: true},
            {
              label: '上一节点审批结果',
              prop: 'nodeState',
              resizable: true,
              hidden: true,
              align: 'center',
              template: function () {
                return '<template scope="scope">\
                <span style="color:gray;" v-if="scope.row.nodeState==\'O-0\'">拿回</span>\
                <span style="color:red;" v-if="scope.row.nodeState==\'O-1\'">打回</span>\
                <span style="color:orange;" v-if="scope.row.nodeState==\'O-2\'">退回</span>\
                <span style="color:gray;" v-if="scope.row.nodeState==\'O-5\'">催办</span>\
                <span style="color:gray;" v-if="scope.row.nodeState==\'O-6\'">转办</span>\
                <span style="color:gray;" v-if="scope.row.nodeState==\'O-7\'">协办</span>\
                <span style="color:gray;" v-if="scope.row.nodeState==\'O-9\'">跳转</span>\
                <span style="color:green;" v-if="scope.row.nodeState==\'O-12\'">同意</span>\
                </template>';
              }
            },
            { label: '流程编号', prop: 'flowId', resizable: true, hidden: true },
            { label: '流程管理员', prop: 'flowAdmin', resizable: true, hidden: true },
            { label: '流程发起者', prop: 'flowStarter', resizable: true, hidden: false},
            { label: '流程发起时间', prop: 'startTime', resizable: true, hidden: true },
            { label: '系统编号', prop: 'systemId', resizable: true, hidden: true },
            { label: '发起人机构', prop: 'orgId', resizable: true, hidden: true },
            {
              label: '流程状态',
              prop: 'flowState',
              resizable: true,
              hidden: false,
              template: function () {
                return '<template scope="scope">\
                <yu-tag type="success" v-if="scope.row.flowState==\'E\'">结束</yu-tag>\
                <yu-tag type="danger" v-if="scope.row.flowState==\'F\'">否决</yu-tag>\
                <yu-tag type="success" v-if="scope.row.flowState==\'R\'">运行中</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.flowState==\'S\'">待发起</yu-tag>\
                </template>';
              }
            },
            { label: '流程参数', prop: 'flowParam', resizable: true, hidden: true },
            { label: '业务类型', prop: 'bizType', resizable: true}
          ],
          formdata: {},
          baseParams: {
            condition: { userId: yufp.session.userCode }
          },
          height: yufp.frame.size().height - 103
        };
      },
      methods: {
        rowDblclick: function (row, event) { // 往实例信息页面跳转
          var _self = this;
          if (row.length < 1) {
            _self.$message({ message: '请先选择一条记录', type: 'warning' });
            return;
          }
          var param = {
            instanceId: row.instanceId,
            userId: row.userId,
            nodeId: row.nodeId,
            isShow: 1,
            type: 'DONE',
            returnBackFuncId: cite.id,
            returnBackRootId: cite.rootId
          };
          yufp.router.to('instanceInfoLite', param, cite.rootId);
        }
      }
    });
  };
});